scrapbox projectのページをrescrapするbookmarklet
code:bookmarklet.js
code:bookmark.js
javascript: (async () => {
const targetProject = window.prompt('Re-scrap this page to...');
// scrapbox以外のページとapiのページはexport対象から外す
if(document.domain != 'scrapbox.io') return;
if(/\w*scrapbox\.io\/api\//.test(document.URL)) return;
const currentProjectName = scrapbox.Project.name;
const currentPageName = scrapbox.Page.title;
// タイトル以外の行を取得する
const rawLines = await fetch(/api/pages/${currentProjectName}/${currentPageName}/text)
.then(res => res.text())
.then(text => text.split('\n'));
const lines = [(via [/${currentProjectName}/${rawLines[0]}]),'/icons/hr.icon',...
rawLines.filter( (_,index) => index !== 0)];
const body= encodeURIComponent(lines.join('\n'));
window.open(https://scrapbox.io/${targetProject}/${currentPageName}?body=${body});
})();